(function () {
    var expect = chai.expect;

    function testStingPrototypeAuiToFirstUpperCase() {
        describe("String.prototype.auiToFirstUpperCase", function () {
            it("'firstuppercase'.auiToFirstUpperCase() == Firstuppercase", function(done) {
                expect('firstuppercase'.auiToFirstUpperCase()).to.equal('Firstuppercase');
                done();
            });
        });
    }

    function testStringPrototypeAuiDashedCaseToCamelCase(params) {
        describe("String.prototype.auiDashedCaseToCamelCase", function () {
            it("'dashed-case'.auiDashedCaseToCamelCase() == dashedCase", function(done) {
                expect('dashed-case'.auiDashedCaseToCamelCase()).to.equal('dashedCase');
                done();
            });
        });
    }

    function testStringPrototypeAuiCamelCaseToDashedCase(params) {
        describe("String.prototype.auiCamelCaseToDashedCase", function () {
            it("'camelCase'.auiCamelCaseToDashedCase() == camel-case", function(done) {
                expect('camelCase'.auiCamelCaseToDashedCase()).to.equal('camel-case');
                done();
            });
        });
    }

    function testArrayPrototypeAuiEnd() {
        describe("Array.prototype.auiEnd", function () {
            it("[].auiEnd == undefined", function(done) {
                expect([].auiEnd).to.be.undefined;
                done();
            });
            it("[1].auiEnd == 1", function(done) {
                expect([1].auiEnd).to.equal(1);
                done();
            })
        });
    }
    
    function testObjectPrototypeAuiGetByPath() {
        var ret = {
            a: 1,
            b: {
                c: "b.c"
            }
        };

        describe("Object.auiGetByPath", function () {
            it("Object.auiGetByPath " + JSON.stringify(ret) + "by key a equal 1", function(done) {
                expect(Object.auiGetByPath(ret, "a")).to.be.equal(1);
                done();
            });         
            it("Object.auiGetByPath " + JSON.stringify(ret) + "by key b.c equal b.c", function(done) {
                expect(Object.auiGetByPath(ret, "b.c")).to.be.equal("b.c");
                done();
            });   
        });
    }

    function testObjectPrototypeAuiSetByPath() {
        var ret = {

        };
        describe("Object.auiSetByPath", function () {
            it("Object.auiSetByPath " + JSON.stringify(ret) + " set a 1", function(done) {
                Object.auiSetByPath(ret, "a", 1)
                expect(ret.a).to.be.equal(1);
                done();
            });         
            it("Object.auiSetByPath " + JSON.stringify(ret) + " set b.c b.c", function(done) {
                Object.auiSetByPath(ret, "b.c", "b.c")
                expect(ret.b.c).to.be.equal("b.c");
                done();
            });         
        });
    }

    function testDatePrototypeFormat() {
        describe("Date.prototype.auiFormat", function () {
            it('new Date(2018,0,1).auiFormat("Y-m-d") equal "2018-01-01" ', function(done) {
                var ret = new Date(2018,0,1).auiFormat("Y-m-d");
                expect(ret).to.be.equal("2018-01-01");
                done();
            });                 
        });
    }


    describe("aui.polyfill", function() {
        testStingPrototypeAuiToFirstUpperCase();
        testStringPrototypeAuiDashedCaseToCamelCase();
        testStringPrototypeAuiCamelCaseToDashedCase();
        testArrayPrototypeAuiEnd();
        testObjectPrototypeAuiGetByPath();
        testObjectPrototypeAuiSetByPath();
        testDatePrototypeFormat();
    });
})();